
package cn.sylinx.web.template.velocity;

import cn.sylinx.web.map.GetRequestMapping;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.TemplateHandler;

/**
 * velocity 请求，一般使用RoutingContext进行reroute
 *
 * @author hanqz
 */
public class VelocityRequestMapping extends GetRequestMapping {

	@Override
	public String path() {
		return VelocityTemplateRender.CONTEXT_PATH_VELOCITY + "/*";
	}

	@Override
	public Handler<RoutingContext> handle() {

		VelocityTemplateEngine velocityEngine = VelocityTemplateEngine.createWithLayout();
		return TemplateHandler.create(velocityEngine, velocityEngine.getTemplateDirectory(),
				velocityEngine.getContentType());
	}

}
